package vn.personal.anhht.bloback12.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

public class SettingActivity extends TabActivity {
    
    private TabHost tabHost;
    private Intent intentSettingCall;
    private Intent intentSettingSMS;
    private Intent intentSettingGeneral;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTabs();
    }
    
    /**
     * Sets the tabs.
     */
    private void setTabs() {
        tabHost = getTabHost();
        intentSettingCall = new Intent(this, TabSettingCallActivity.class);
        intentSettingSMS = new Intent(this, TabSettingSmsActivity.class);
        intentSettingGeneral = new Intent(this, TabSettingGeneralActivity.class);
        addTabs("General Setting", R.drawable.tab_smslog,
                intentSettingGeneral);
        addTabs("Call Setting", R.drawable.tab_call,
                intentSettingCall);
        addTabs("SMS Setting", R.drawable.tab_smslog,
                intentSettingSMS);
    }

    /**
     * Adds the tabs.
     */
    public void addTabs(String label, int icon, Intent intent) {

        TabHost.TabSpec tabSpec = tabHost.newTabSpec("tab" + label);
        View tabIndicator = LayoutInflater.from(this).inflate(
                R.layout.tab_indocator, getTabWidget(), false);
        TextView title = (TextView) tabIndicator.findViewById(R.id.title);
        title.setText(label);
        ImageView icon1 = (ImageView) tabIndicator.findViewById(R.id.icon);
        icon1.setImageResource(icon);
        tabSpec.setIndicator(tabIndicator);
        tabSpec.setContent(intent);
        tabHost.addTab(tabSpec);
    }
}
